package spring_mybatis.test;

import org.databene.contiperf.PerfTest;
import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import www.albert.springMybatis.dao.UserDao;
import www.albert.springMybatis.entry.User;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext-DAO.xml"})
public class SMTest_DAO {
    @Rule
    public ContiPerfRule i = new ContiPerfRule();
    
    
    @Autowired
    private UserDao userDao;
    
    @Test
    @Transactional
    @PerfTest(invocations = 200000, threads = 100)
    public void findUserById() {
        System.out.println("start");
        User user = userDao.findUserById(1);
        System.out.println(user.toString());
        System.out.println("end");
    }
    
    @Test
    @Transactional
    public void deleteUser() {
        System.out.println("start");
        userDao.deleteUser(1);
        System.out.println("end");
    }
    
    @Test
    @Transactional
    public void insertUser() {
        System.out.println("start");
        userDao.insertUser(null);
        System.out.println("end");
    }

}
